﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Sealight.Core.Domain
{
   public class CategoryEntity:BaseEntity
    {
        /// <summary>
        /// Gets or sets the category identifier
        /// </summary>
        public virtual Guid CategoryID { get; set; }

        /// <summary>
        /// Gets or sets the name
        /// </summary>
        public virtual string Name { get; set; }
        public virtual Guid? ParentID { get; set; }
        /// <summary>
        /// Gets or sets the description
        /// </summary>
        public virtual string Description { get; set; }
       
        /// <summary>
        /// Gets or sets the meta keywords
        /// </summary>
        public virtual string MetaKeywords { get; set; }

        /// <summary>
        /// Gets or sets the meta description
        /// </summary>
        public virtual string MetaDescription { get; set; }

        /// <summary>
        /// Gets or sets the meta title
        /// </summary>
        public virtual string MetaTitle { get; set; }

        /// <summary>
        /// Gets or sets the search-engine name
        /// </summary>
        public virtual string SEName { get; set; }       
      
        /// <summary>
        /// Gets or sets the page size
        /// </summary>
        public virtual int PageSize { get; set; }

        /// <summary>
        /// Gets or sets the available price ranges
        /// </summary>
        public virtual string PriceRanges { get; set; }

        /// <summary>
        /// Gets or sets a value indicating whether the entity is published
        /// </summary>
        public virtual bool Published { get; set; }

        /// <summary>
        /// Gets or sets a value indicating whether the entity has been deleted
        /// </summary>
        public virtual bool Deleted { get; set; }

        /// <summary>
        /// Gets or sets the display order
        /// </summary>
        public virtual int DisplayOrder { get; set; }

        /// <summary>
        /// Gets or sets the date and time of instance creation
        /// </summary>
        public virtual DateTime CreatedDate { get; set; }

        /// <summary>
        /// Gets or sets the date and time of instance update
        /// </summary>
        public virtual DateTime ModifiedDate { get; set; }

        /// <summary>
        /// Gets or sets the picture identifier
        /// </summary>
        public virtual PictureEntity Picture { get; set; }
        public virtual IList<CategoryEntity> Childrens { get; set; }

        public virtual Sealight.Core.DataAdapter.product_category ToDataAdapter()
        {
             DataAdapter.product_category data= new DataAdapter.product_category {id=this.CategoryID, name = this.Name, created_date=this.CreatedDate, deleted=this.Deleted, 
                 description=this.Description, meta_description=this.MetaDescription, display_order=this.DisplayOrder,
             meta_keywords = this.MetaKeywords, meta_title=this.MetaTitle, modified_date = this.ModifiedDate, page_size=this.PageSize, parent_id=this.ParentID,
             published=this.Published, se_name=this.SEName, price_ranges=this.PriceRanges};

             if (this.Picture != null) data.picture = this.Picture.ToDataAdapter();
             if (this.Childrens != null)
             {
                 data.childrens = (from c in this.Childrens select c.ToDataAdapter()).ToList();
             }

             return data;
        }
    }
}
